###############################################################################
# SuperLinks                                                                  #
# Copyright (c) 2000-2007 Greg Nolle (http://greg.nolle.co.uk)                #
###############################################################################
# This program is free software; you can redistribute it and/or modify it     #
# under the terms of the GNU General Public License as published by the Free  #
# Software Foundation; either version 2 of the License, or (at your option)   #
# any later version.                                                          #
#                                                                             #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   #
# more details.                                                               ##                                                                             #
# You should have received a copy of the GNU General Public License along     #
# with this program; if not, write to the Free Software Foundation, Inc.,     #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 #
###############################################################################
# ControlPanel/Output/RestoreBackup.pm.pl -> RestoreBackup module             #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::CP::RestoreBackup;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use HTML::Dialog;
use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  my $Body = $Dialog->TableRow(items => [{ body => "Are you sure you want to restore this backup?", colspan => 2 }]);

  $Body .= $Dialog->FormCheckBox(
    name    => "FORM_RESTORE_SKINS",
    value   => "1",
    subject => "Also Restore",
    items   => [
      { value => "1", label => "Skins (if available)" }
    ]
  );

  $Body .= $Dialog->FormCheckBox(
    name    => "FORM_RESTORE_STYLESHEETS",
    value   => "1",
    items   => [
      { value => "1", label => "Stylesheets (if available)" }
    ]
  );

  $Body .= $Dialog->FormCheckBox(
    name    => "FORM_RESTORE_TEMPLATESETS",
    value   => "1",
    items   => [
      { value => "1", label => "Template Sets (if available)" }
    ]
  );

  $Body .= $Dialog->FormCheckBox(
    name    => "FORM_RESTORE_LANGUAGESETS",
    value   => "1",
    items   => [
      { value => "1", label => "Language Sets (if available)" }
    ]
  );

  $Body .= $Dialog->FormButton(
    items   => [
      { type => "submit", value => "Restore" },
      { type => "reset", value => "Cancel" }
    ], join => "&nbsp;"
  );

  $Body = $Dialog->Table(body => $Body);
  $Body = $Dialog->StandardPage(
    body    => $Body,
    header  => "Restore Backup",
    form    => 1,
    hiddens => [
      { name => "BID", value => $SL::QUERY{'BID'} },
      { name => "action", value => "DoRestoreBackup" },
      { name => "CP", value => "1" },
      { name => "SID", value => $SL::ADMIN{'SID'} }
    ]
  );
  
  return $Body;
}

###############################################################################
# do subroutine
sub do {
  my $self = shift;
  my ($section) = @_;

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  my $Body  = $Dialog->TableRow(items => [{ body => "Restoring database:", colspan => 2 }]);
     $Body .= $Dialog->TableRow(items => [{ body => "<iframe src=\"".$SL::CGI->self_url()."&do=1\" name=\"LOG\" height=\"300\" width=\"100%\"></iframe>", colspan => 2 }]);

  $Body .= $Dialog->FormButton(
    items => [
      { type => "button", value => "Close", extra => { onClick => "window.location='".($SL::QUERY{'Referer'} || "$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Backups&SID=$SL::ADMIN{'SID'}")."';" } }
    ]
  );
  
  $Body = $Dialog->Table(body => $Body);
  $Body = $Dialog->StandardPage(
    body        => $Body,
    header      => "Restore Backup",
    body_extra  => "onLoad=\"document.LOG.scrollTo(0, 9999999);\""
  );
  
  return $Body;
}

1;